﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using Telerik.WinControls.UI;
using LIM.controller;
using LIM.model;

namespace LIM.forms
{
    public partial class radForm_CRM_NhatKyLienLac : Telerik.WinControls.UI.RadForm
    {
        public radForm_CRM_NhatKyLienLac()
        {
            InitializeComponent();
            radMenuComboItem1.ComboBoxElement.DropDownStyle = RadDropDownStyle.DropDownList;
            radMenuComboItem1.ComboBoxElement.DataSource = controller.loadNhanVien();
            radMenuComboItem1.ComboBoxElement.DisplayMember = "HoTen";
            radMenuComboItem1.ComboBoxElement.ValueMember = "RowID";
        }
        DanhMucLienHeController controller = new DanhMucLienHeController();
        private void radMenuItem_TaoMoi_Click(object sender, EventArgs e)
        {
            radForm_CRM_LienLac_ChiTiet form = new radForm_CRM_LienLac_ChiTiet();
            form.Controller = controller;
            form.MdiParent = this.MdiParent;
            form.Show();
        }
        private void radForm_CRM_NhatKyLienLac_Load(object sender, EventArgs e)
        {
            radGridView2.DataSource =controller.LoadNhatKyLienLac(null);

        }

        private void radMenuComboItem1_ComboBoxElement_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
        {
            if (radMenuComboItem1.ComboBoxElement.SelectedItem.DataBoundItem != null)
            {
                int ID = ((tbl_DanhMuc_ThongTinNhanVien)radMenuComboItem1.ComboBoxElement.SelectedItem.DataBoundItem).RowID;
                radGridView2.DataSource = controller.LoadNhatKyLienLac(ID);
            }
        }

        private void radMenuItem1_Click(object sender, EventArgs e)
        {
            if (radMenuComboItem1.ComboBoxElement.SelectedItem.DataBoundItem != null)
            {
                int ID = ((tbl_DanhMuc_ThongTinNhanVien)radMenuComboItem1.ComboBoxElement.SelectedItem.DataBoundItem).RowID;
                radGridView2.DataSource = controller.LoadNhatKyLienLac(ID);
            }
        }

        private void radMenuComboItem1_Click(object sender, EventArgs e)
        {

        }

        private void radGridView2_CellDoubleClick(object sender, GridViewCellEventArgs e)
        {
            if (radGridView2.SelectedRows.Count > 0)
            {
                if (radGridView2.SelectedRows[0].Cells[0].Value != null)
                {
                    radForm_CRM_LienLac_ChiTiet form = new radForm_CRM_LienLac_ChiTiet();
                    form.Controller = controller;
                    form.MdiParent = this.MdiParent;
                    form.RowID = int.Parse(radGridView2.SelectedRows[0].Cells[0].Value.ToString());
                    form.Show();

                }
            }
        }
    }
}
